import time

def bubble_sorter(nums):

    swapped = True
    while swapped:
        swapped = False
        for i in range(len(nums) - 1):
            if nums[i] > nums[i + 1]:
                # Меняем элементы
                nums[i], nums[i + 1] = nums[i + 1], nums[i]
                # Устанавливаем swapped в True для следующей итерации
                swapped = True

def readTolist(filename):
    file = open(filename, 'r')
    data = file.readlines()
    return data

m1 = readTolist("m1_sorted.txt")
m2 = readTolist("m2_reverse.txt")
m3 = readTolist("m3_shuffle.txt")

Tstart = time.time()
bubble_sorter(m1)
Tfinish = time.time()
print("m1_sorted",round((t_finish-t_start)*1000),"milliseconds")

Tstart = time.time()
bubble_sorter(m2)
Tfinish = time.time()
print("m2_reverse",round((t_finish-t_start)*1000),"milliseconds")

Tstart = time.time()
bubble_sorter(m3)
Tfinish = time.time()
print("m3_shuffle",round((t_finish-t_start)*1000),"milliseconds")